import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询文章列表
export function listArticle(data) {
  return request({
    url: '/market/article/articleList',
    method: 'post',
    data: data
  })
}

// 查询文章详细
export function getArticle(articleId) {
  return request({
    url: '/market/article/' + parseStrEmpty(articleId),
    method: 'get'
  })
}

// 新增文章
export function addArticle(data) {
  return request({
    url: '/market/article',
    method: 'post',
    data: data
  })
}

// 检查文章是否存在 获取类型文章
export function checkArticleUnique(data) {
  return request({
    url: '/market/article/checkArticleUnique',
    method: 'post',
    data: data
  })
}

// 保存文章
export function saveArticle(data) {
  return request({
    url: '/market/article/articleSave',
    method: 'post',
    data: data
  })
}

// 修改文章
export function updateArticle(data) {
  return request({
    url: '/market/article',
    method: 'put',
    data: data
  })
}

// 删除文章
export function delArticle(articleId) {
  return request({
    url: '/market/article/' + articleId,
    method: 'delete'
  })
}

// 文章状态修改
export function changeArticleStatus(articleId, status) {
  const data = {
    articleId,
    status
  }
  return request({
    url: '/market/article/articleChangeStatus',
    method: 'put',
    data: data
  })
}
